package dao;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.alibaba.druid.util.JdbcUtils;
import javax.sql.DataSource;
import java.io.InputStream;
import java.util.Properties;

public class JDBCUtil {
    private static DataSource dataSource;

    public  static  DataSource getDatasource(){
        try {
            InputStream is = JdbcUtils.class.getClassLoader().getResourceAsStream("JDBC.properties");
            Properties prop = new Properties();
            prop.load(is);
            dataSource= DruidDataSourceFactory.createDataSource(prop);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dataSource;
    }


}
